package com.cx.controller;

import com.cx.util.Epidemic;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.Date;
import java.util.List;

/**
 * @Description
 * @Author 11597
 * @Date 2020/6/5 16:12
 */
@Controller
public class epidemic {

    Long domesticdate;
    Long externaldate;
    Long provincedate;
    String domesticString;
    String externalString;
    String provinceString;


    @RequestMapping("epidemic")
    public String epidemic(HttpSession session){
        return "epidemic";
    }


    @RequestMapping("domestic")
    @ResponseBody
    public String domestic(HttpSession session){
        long currentTime = System.currentTimeMillis();
        if(domesticdate==null||currentTime>(domesticdate+ 60 * 60 * 1000)){
            domesticdate = currentTime;
            Epidemic epidemic = new Epidemic();
            domesticString = epidemic.domestic();
            System.out.println(domesticString);
            return domesticString;
        }
        return domesticString;
    }


    @RequestMapping("external")
    @ResponseBody
    public String external(HttpSession session){
        long currentTime = System.currentTimeMillis();
        if(externaldate==null||currentTime>(externaldate+ 60 * 60 * 1000)){
            externaldate = currentTime;
            Epidemic epidemic = new Epidemic();
            externalString = epidemic.external();
            System.out.println(externalString);
            return externalString;
        }
        return externalString;
    }

    @RequestMapping("province")
    @ResponseBody
    public String province(HttpSession session){
        long currentTime = System.currentTimeMillis();
        if(provincedate==null||currentTime>(provincedate+ 60 * 60 * 1000)){
            provincedate = currentTime;
            Epidemic epidemic = new Epidemic();
            provinceString = epidemic.province();
            System.out.println(provinceString);
            return provinceString;
        }
        return provinceString;
    }


}
